package org.osomit.sacct.entity;

import org.json.simple.JSONObject;
import org.json.simple.JSONArray;

import java.util.List;

/**
 * @author Jian Fang (John.Jian.Fang@gmail.com)
 * 
 * Date: Jun 30, 2009
 */
public class ApplicationAccountRecordSet extends Entity{
    private static final long serialVersionUID = -189444934609072425L;
    
    public final static String ENTITY_NAME = "ApplicationAccountRecordSet";

    public final static String RECORDS = "records";
    private List<ApplicationAccountRecord> records;

    public List<ApplicationAccountRecord> getRecords() {
        return records;
    }

    public void setRecords(List<ApplicationAccountRecord> records) {
        this.records = records;
    }

    public JSONObject toJSON() {
        JSONObject obj = new JSONObject();
        JSONArray arr = new JSONArray();
        if(records != null && records.size() > 0){
            for(ApplicationAccountRecord record: records){
                arr.add(record.toJSON());
            }
        }

        obj.put(RECORDS, arr);

        return obj;
    }
}
